# !/usr/bin/env python
# coding=utf-8
# @Time    : 2018/7/16 10:08
# @Author  : 6imensiva
# @Site    : https://gitee.com/dimensiva/rpc_dao.git
# @File    : unit_test.py
# @Software: PyCharm
# @Version: 2.7.5
import unittest
from db import car_raw_info


def get_variable_name(x):
    for k,v in locals().items():
        if v is x:
            return k

def aaa(a):
	print(get_variable_name(a), '=', a)


class UnitTestCase(unittest.TestCase):
	def setUp(self):
		pass

	def tearDown(self):
		pass

	# def test_db_update(self):
	# 	from db.models import TCarRawinfo
	# 	from db import Session
	# 	session = Session()
	# 	session.query()
	# 	ret = session.query(TCarRawinfo).filter_by(licenseNo='川AJ76D5').update({
	# 		TCarRawinfo.is_trans: None,
	# 	})
	# 	print('aaaaa', ret, type(ret))
	# 	session.commit()
	#
	# def test_db_insert(self):
	# 	from db.models import TInsuranceType
	# 	from db import Session
	# 	session = Session()
	# 	try:
	# 		aaa = session.execute(
	# 			TInsuranceType.__table__.insert(),
	# 			{'code': 'aaa',
	# 			 'type_name': 'bbb',
	# 			 'amount_range': 'ccc',
	# 			 'description': 'ddd',
	# 			 'status': 123,
	# 			 }
	# 		)
	# 		session.commit()
	# 		last_insert_id = aaa.lastrowid
	# 		print('aaaaa', last_insert_id)
	# 	except Exception as e:
	# 		session.rollback()
	# 		print(e)
	# 	# print('aaa', aaa)
	#
	# def test_thrift_map(self):
	# 	from service import insurance_types_list
	# 	insurance_types_list.get_tpic_map()
	#
	# def test_add_user(self):
	# 	from service import user_service
	# 	from idl_output.structs.ttypes import UserProfile
	# 	a = UserProfile(user_name='aaa')
	# 	print(user_service.add_user(a))

	def test_update_user(self):
		from db import user_dao
		from idl_output.ttypes import UserProfile
		a = UserProfile(id=51, user_name='ccc', pwd='uuuu')
		user_dao.update_user(a)

	def test_dict(self):
		# import os
		# path = '../py3_utils'
		# for dirpath, dirnames, filenames in os.walk(path):
		# 	for file in filenames:
		# 		print(file)
		import py3_utils
		from py3_utils.my_time import  _Timer
		from py3_utils.my_sqlalchemy import MyUpdateDict

	def test_get_car_info(self):
		from service import car_raw_info_service
		print(car_raw_info_service.get_car_raw_info_by_license('川AJ76D5'))



if __name__ == '__main__':
	# unittest.main()
	import py3_utils
	from py3_utils.my_time import _Timer
	from py3_utils.my_sqlalchemy import MyUpdateDict
